/*****************************************************************************
*                               CEM Inc.                              *
*                                                                            *
******************************************************************************
*                                                                            *
*                                                                            *
*            ###   #     #  #####  #       #     # ######  #######           *
*             #    ##    # #     # #       #     # #     # #                 *
*             #    # #   # #       #       #     # #     # #                 *
*             #    #  #  # #       #       #     # #     # #####             *
*             #    #   # # #       #       #     # #     # #                 *
*             #    #    ## #     # #       #     # #     # #                 *
*            ###   #     #  #####  #######  #####  ######  #######           *
*                                                                            *
*                                                                            *
*            #####  #     # #     # ######  ####### #        #####           *
*           #     #  #   #  ##   ## #     # #     # #       #     #          *
*           #         # #   # # # # #     # #     # #       #                *
*            #####     #    #  #  # ######  #     # #        #####           *
*                 #    #    #     # #     # #     # #             #          *
*           #     #    #    #     # #     # #     # #       #     #          *
*            #####     #    #     # ######  ####### #######  #####           *
*                                                                            *
*                                                                            *
******************************************************************************
*
*            Title: PROPAK CODE Global Definition Include File
*      Part Number: si-03663-09
*        $Revision: 1.1 $
*            $Date: 2013/02/06 09:28:41 $
*          $Source: /spx1/sw/TRE-16577-00/MEM-16245-00/src/mod_03663/si_03663.h,v $
*
******************************************************************************
*                                                                            *
*                             PROPRIETARY LEGEND                             *
*                                                                            *
*            (C) Copyright CEM Inc, 2013, All Rights Reserved.        *
*                                                                            *
*      The information contained herein or herewith is the  confidential     *
*      and proprietary property of CEM Inc. The information shall     *
*      not, in whole or in part, be  reproduced,  copied,  disclosed  or     *
*      used  other than as expressly authorized by written permission of     *
*      CEM Inc.  The copyright and the foregoing  restriction  on     *
*      reproduction, copy, disclosure and use extend to all the media in     *
*      which this information may be  embodied,  including  magnetic  or     *
*      electronic  storage,  punch card, paper tape, computer print-out,     *
*      visual display, etc.                                                  *
*                                                                            *******************************************************************************

******************************************************************************
*                   R E V I S I O N      H I S T O R Y                       *
******************************************************************************
*
 *
******************************************************************************

******************************************************************************
*                      I N C L U D E       F I L E S
*****************************************************************************/
#ifndef DATATYPE_H_
#define DATATYPE_H_

/* none */

/*****************************************************************************
*                   C O N S T A N T S
*****************************************************************************/

#define FALSE   (0)
#define NULL    (0)
#define TRUE    (1)

/*****************************************************************************
*                   T Y P E     D E F I N I T I O N S
*****************************************************************************/

/* these typedefs are there to insure portability of the code to other
   processors */

typedef unsigned char  INT8;
typedef char           SINT8;
typedef unsigned short INT16;
typedef short          SINT16;
typedef unsigned int   INT32;
typedef int            SINT32;

typedef unsigned long   UINT32;
typedef unsigned short  UINT16;
typedef unsigned char   UINT8;

typedef INT16 INST_ID;
typedef INT16 PB_ID;
typedef INT16 ZN_ID;

typedef struct {
  INT8 node;
  INT8 loop;
  INT8 dev;
} Idv, Odv;

typedef unsigned char REVISION;  // e.g. REV_FWS01
typedef unsigned int  INDEX;     // list, array index
typedef unsigned int  COUNT;     // e.g. number of lines in cfg file
typedef unsigned char BYTE;
typedef unsigned int WORD;

typedef enum {
	RTN_ERROR_GEN = -1,
	RTN_ERR_CFG_INVALID = -2,
	RTN_ERR_FWS_DOESNT_DRIVE_SO = -3,
	RTN_ERR_OBJECT_DOES_NOT_EXIST = -4,
	RTN_SUCCESS = 1,
	RTN_CFG_VALID = 2
}RTN_TYPE;
typedef enum booltag
{
	false=0,
	true=1
} bool_t;
#endif /* DATATYPE_H_ */

/*****************************************************************************
*                               Securiplex Inc.                              *
*                                                                            *
******************************************************************************
*                                                                            *
*                                                                            *
*            ###   #     #  #####  #       #     # ######  #######           *
*             #    ##    # #     # #       #     # #     # #                 *
*             #    # #   # #       #       #     # #     # #                 *
*             #    #  #  # #       #       #     # #     # #####             *
*             #    #   # # #       #       #     # #     # #                 *
*             #    #    ## #     # #       #     # #     # #                 *
*            ###   #     #  #####  #######  #####  ######  #######           *
*                                                                            *
*                                                                            *
*            #####  #     # #     # ######  ####### #        #####           *
*           #     #  #   #  ##   ## #     # #     # #       #     #          *
*           #         # #   # # # # #     # #     # #       #                *
*            #####     #    #  #  # ######  #     # #        #####           *
*                 #    #    #     # #     # #     # #             #          *
*           #     #    #    #     # #     # #     # #       #     #          *
*            #####     #    #     # ######  ####### #######  #####           *
*                                                                            *
*                                                                            *
******************************************************************************
*
*            Title: PROPAK CODE Configuration include file
*      Part Number: si-03666-09
*        $Revision: 1.1 $
*            $Date: 2003/02/06 09:29:32 $
*          $Source: /spx1/sw/TRE-16577-00/MEM-16245-00/src/mod_03666/si_03666.h,v $
*
******************************************************************************
*                                                                            *
*                             PROPRIETARY LEGEND                             *
*                                                                            *
*            (C) Copyright Securiplex Inc, 2003, All Rights Reserved.        *
*                                                                            *
*      The information contained herein or herewith is the  confidential     *
*      and proprietary property of Securiplex Inc. The information shall     *
*      not, in whole or in part, be  reproduced,  copied,  disclosed  or     *
*      used  other than as expressly authorized by written permission of     *
*      Securiplex Inc.  The copyright and the foregoing  restriction  on     *
*      reproduction, copy, disclosure and use extend to all the media in     *
*      which this information may be  embodied,  including  magnetic  or     *
*      electronic  storage,  punch card, paper tape, computer print-out,     *
*      visual display, etc.                                                  *
*                                                                            *
******************************************************************************

******************************************************************************
*                   R E V I S I O N      H I S T O R Y                       *
******************************************************************************
* $Log:	si_03666.h,v $
 * Revision 1.1  2003/02/06  09:29:32  09:29:32  patrickt (Patrick Therien)
 * Initial revision
 *
******************************************************************************

******************************************************************************
*                      I N C L U D E       F I L E S
*****************************************************************************/

#ifndef __SI_03666__

#define __SI_03666__

/* NONE */

/*****************************************************************************
*                   C O N S T A N T S
*****************************************************************************/

/**************************************************
* 68302 TIMER REGISTERS DEFINE					  *
**************************************************/

/*****************************************************************************
                    TASK CONTROL DEFINITIONS
*****************************************************************************/


/*****************************************************************************
                    ERROR HANDLER ERROR NUMBERS
*****************************************************************************/

/* FATAL ERROR CODES */

/* standard 68000 vector table error codes (all fatal errors) */
#define FERR_BUS       (-1)
#define FERR_ADDRESS   (-2)
#define FERR_ILL_INST  (-3)
#define FERR_ZERO_DIVD (-4)
#define FERR_CHECK     (-5)
#define FERR_TRAPV     (-6)
#define FERR_PRIVILEGE (-7)
#define FERR_TRACE     (-8)
#define FERR_LINE_1010 (-9)
#define FERR_LINE_1111 (-10)
#define FERR_SPURIOUS  (-11)
#define FERR_INTERRUPT (-12)
#define FERR_TRAP_0    (-19)
#define FERR_TRAP_1    (-20)
#define FERR_TRAP_2    (-21)
#define FERR_TRAP_3    (-22)
#define FERR_TRAP_4    (-23)
#define FERR_TRAP_5    (-24)
#define FERR_TRAP_6    (-25)
#define FERR_TRAP_7    (-26)
#define FERR_TRAP_8    (-27)
#define FERR_TRAP_9    (-28)
#define FERR_TRAP_A    (-29)
#define FERR_TRAP_B    (-30)
#define FERR_TRAP_C    (-31)
#define FERR_TRAP_D    (-32)
#define FERR_TRAP_E    (-33)
#define FERR_TRAP_F    (-34)

#define FERR_PUP_RAM   (-35)

/* applications fatal error codes */
#define FERR_03665_00  (-36)
#define FERR_03665_01  (-37)
#define FERR_03665_02  (-38)
#define FERR_03665_03  (-39)
#define FERR_03665_04  (-40)
#define FERR_03665_05  (-41)
#define FERR_03665_06  (-42)
#define FERR_03667_00  (-43)
#define FERR_03667_01  (-44)
#define FERR_03667_02  (-45)
#define FERR_03667_03  (-46)
#define FERR_03668_00  (-47)
#define FERR_03668_01  (-48)
#define FERR_03668_02  (-49)
#define FERR_03668_03  (-50)
#define FERR_03671_00  (-51)
#define FERR_03671_01  (-52)
#define FERR_03671_02  (-53)
#define FERR_03671_03  (-54)
#define FERR_03672_00  (-55)
#define FERR_03673_00  (-56)
#define FERR_03673_01  (-57)
#define FERR_03673_02  (-58)
#define FERR_03673_03  (-59)
#define FERR_03676_00  (-60)
#define FERR_03676_01  (-61)
#define FERR_03677_00  (-62)
#define FERR_03678_00  (-63)
#define FERR_03678_01  (-64)
#define FERR_03679_00  (-65)
#define FERR_03679_01  (-66)
#define FERR_03680_00  (-67)
#define FERR_03680_01  (-68)
#define FERR_03680_02  (-69)
#define FERR_03680_03  (-70)
#define FERR_03680_04  (-71)
#define FERR_03680_05  (-72)

#define FERR_03681_01  (-73)

#define FERR_03682_01  (-74)
#define FERR_03682_02  (-75)
/*                     (-76)  SPARE */

#define FERR_03683_01  (-77)
#define FERR_03683_02  (-78)
#define FERR_03683_03  (-79)
#define FERR_03683_04  (-80)

#define FERR_03684_01  (-81)

#define FERR_03685_01  (-82)
#define FERR_03685_02  (-83)
#define FERR_03685_03  (-84)
#define FERR_03685_04  (-85)
#define FERR_03685_05  (-86)
#define FERR_03685_06  (-87)
#define FERR_03685_07  (-88)
#define FERR_03685_08  (-89)
#define FERR_03685_09  (-90)
#define FERR_03685_10  (-91)
#define FERR_03685_11  (-92)
#define FERR_03685_12  (-93)
#define FERR_03685_13  (-94)
#define FERR_03685_14  (-95)
#define FERR_03685_15  (-96)
#define FERR_03685_16  (-97)
#define FERR_03685_17  (-98)
#define FERR_03685_18  (-99)
#define FERR_03685_19  (-100)

#define FERR_03694_01  (-101)
#define FERR_12476_01  (-102)
#define FERR_16645_01  (-103)
#define FERR_16645_02  (-104)
#define FERR_16645_03  (-105)
#define FERR_16647_01  (-106)
#define FERR_16647_02  (-107)

#define NUM_ERROR_CODE 20

/*****************************************************************************
                    EEPROM
*****************************************************************************/

/*****************************************************************************
*                   T Y P E     D E F I N I T I O N S
*****************************************************************************/

/* this union includes all event types subject to be in a mailbox */

typedef struct {
  INT16    type;          /* defines the type of event present   */
  INST_ID  inst_id;       /* define the number of inst id present*/
  INT8     data[28];      /* 31 bytes of data space              */
} Mbox_event;

typedef struct {
  INT32 hours    :  5;    /* 0-23 or 1-12 (msb: 0-> AM 1->PM) */
  INT32 minutes  :  6;    /* 0-59     */
  INT32 day      :  5;    /* 1-31     */
  INT32 month    :  4;    /* 1-12     */
  INT32 year     : 12;    /* 0 - 4095 */
} Date;

typedef struct {
  ZN_ID zn_id;
}Zone_event;


typedef struct {
  INT8 jmp_instr[ 2 ];                 /* JMP.L instruction */
  void  *p_vector;                     /* jump_to_Vector    */
} Jmp_table;

enum {
  JT_RESET,
  JT_EXCEPT_BUS_ERR,                    /* 0 */
  JT_EXCEPT_ADD_ERR,
  JT_EXCEPT_ILL_ERR,
  JT_EXCEPT_ZERO_ERR,
  JT_EXCEPT_CHK_ERR,
  JT_EXCEPT_TRAPV_ERR,
  JT_EXCEPT_PRIV_ERR,
  JT_EXCEPT_TRACE_ERR,
  JT_EXCEPT_1010_ERR,
  JT_EXCEPT_1111_ERR,
  JT_EXCEPT_BAD_VECTOR,                 /* 10 */
  JT_EXCEPT_SPUR_ERR,
  JT_LEVEL_1_INT,
  JT_LEVEL_2_INT,
  JT_LEVEL_3_INT,
  JT_LEVEL_4_INT,
  JT_LEVEL_5_INT,
  JT_COMM_CARD_INT,
  JT_PARITY_24V_INT,
  JT_SET_INTERRUPT_LEVEL,
  JT_SYSTEM_CALL,                       /* 20 */
  JT_EXEC_TRAP2,
  JT_EXEC_TRAP3,
  JT_EXEC_TRAP4,
  JT_EXEC_TRAP5,
  JT_EXEC_TRAP6,
  JT_EXEC_TRAP7,
  JT_EXEC_TRAP8,
  JT_EXEC_TRAP9,
  JT_EXEC_TRAPA,                        /* 30 */
  JT_EXEC_TRAPB,
  JT_EXEC_TRAPC,
  JT_EXEC_TRAPD,
  JT_EXEC_TRAPF,
  JT_ERROR_ISR,
  JT_PB8_ISR,
  JT_SMC2_ISR,
  JT_SMC1_ISR,
  JT_TIM3_ISR,                          /* 40 */
  JT_SCP_ISR,
  JT_TIM2_ISR,
  JT_PB9_ISR,
  JT_SCC3_ISR,
  JT_TIM1_ISR,
  JT_SCC2_ISR,
  JT_IDMA_ISR,
  JT_DMAE_ISR,
  JT_SCC1_ISR,
  JT_PB10_ISR,                          /* 50 */
  JT_RTC_INTERRUPT,
  JT_MC302_BAD_VECT_ISR,
  JT_MC302_LVL_1_ISR,
  JT_MC302_LVL_2_ISR,
  JT_MC302_LVL_3_ISR,
  JT_MC302_LVL_4_ISR,
  JT_MC302_LVL_5_ISR,
  JT_MC302_LVL_6_ISR,
  JT_MC302_LVL_7_ISR,                  /* 59 */
  JT_TOTAL                             /* Total 60 */
};

void err_hdl(INT32 part_num, SINT32 err_code);

void __SET_INTERRUPT_LEVEL(void);

#ifdef _SDS
#  define DO_ASM asm
#else
#  define DO_ASM __asm
#endif



#endif /* __SI_03666__ */
